<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>毕业倒计时</title>
    <meta name="author" content="373">
    <style>
        div,
        p,
        h1,
        h2,
        h3 {
            font-size: 4rem;
            line-height: 1em;
            display: flex;
            flex-direction: column;
            justify-content: center;
            font-family: Courier, "微软雅黑", sans-serif;
            font-family: Courier, "Microsoft Yahei", sans-serif;
        }

        * {
            font-weight: lighter;
            text-align: center;
            margin: 0 auto;
            height: 100%;
            width: 100%;
        }
    </style>
</head>

<body>
    <div id="contdown" class="contdown"></div>
    <script type="text/javascript">
        window.onload = function () {
            showtime();
            function leftPad(n, len) {
                len = len || 2;
                n = n + '';
                var diff = len - n.length;
                if (diff > 0) {
                    n = new Array(diff + 1).join('0') + n;
                }
                return n;
            }
            function showtime() {
                var nowtime = new Date();
                var endtime = new Date("2020/07/20,00:00:00");
                var lefttime = parseInt((endtime.getTime() - nowtime.getTime()) / 1000);
                var d = parseInt(lefttime / (24 * 60 * 60));
                var h = parseInt(lefttime / (60 * 60) % 24);
                var m = parseInt(lefttime / 60 % 60);
                var s = parseInt(lefttime % 60);
                d = leftPad(d, 2);
                h = leftPad(h, 2);
                m = leftPad(m, 2);
                s = leftPad(s, 2);
                if (window.innerHeight >= window.innerWidth) {
                    document.getElementById("contdown").style.fontSize = "6rem"
                    document.getElementById("contdown").innerHTML = "距离毕业还剩:<br \\>" + d + "天<br \\>" + h + "时<br \\>" + m + "分<br \\>" + s + "秒";
                } else {
                    document.getElementById("contdown").style.fontSize = "4rem"
                    document.getElementById("contdown").innerHTML = "距离毕业还剩：    " + d + "天 " + h + "时 " + m + "分 " + s + "秒";
                }
                if (lefttime <= 0) {
                    document.getElementById("contdown").innerHTML = "毕业了。。？";
                    return;
                }
                setTimeout(showtime, 1000);
            }
        }
    </script>
</body>

</html>